define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'echarts', 'echarts-theme'], function ($, undefined, Backend, Table, Form, Template, Echarts) {

    var Controller = {
        index: function () {
            console.log(Echarts.version);
            var barChart = Echarts.init(document.getElementById('smoothline-chart'));
            option = {
                textStyle: {
                    color: "#fff"
                },
                tooltip: {
                    trigger: 'axis'
                },
                color: ['#fff'],
                legend: {
                    data: ['统计图'],
                    icon : 'roundRect',//icon为圆角矩形
                    textStyle:{//图例文字的样式
                        color:'#fff',
                        fontSize:16
                    }
                },   
                grid: {
                    left: '2%',
                    right: '2%',
                    bottom: '3%',
                    containLabel: true
                },                                            
                xAxis: {
                    type: 'category',
                    boundaryGap:false,
                    // data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
                    data:Orderdata.column,
                    axisLine: {
                        lineStyle: {
                            color: "#fff"
                        }
                    }
                },
                yAxis: {
                    type: 'value',
                    splitLine: {
                        show: false
                    },
                    axisLine: {
                        lineStyle: {
                            color: "#fff"
                        }
                    }
                },
                series: [{
                    name:'预约数量',
                    // data: [820, 1330, 901, 934, 1290, 500, 1320],
                    data:Orderdata.paydata,
                    type: 'line',
                    smooth: true,
                    areaStyle: {
                        opacity: 0.4
                    }

                }]
            };

            $(document).on("click", ".btn-yester", function () {
                //在table外不可以使用添加.btn-change的方法
                var type = $(this).attr('type');
                Fast.api.ajax({
                    data: {type:type},
                    url: "reserve_statistics",
                    type: "get",
                    success: function (res) {
                        Layer.closeAll();
                        if (res.code == 1) {
                            var column = res.data.column;
                            var paydata = res.data.paydata;
                            option = {
                                textStyle: {
                                    color: "#fff"
                                },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                color: ['#fff'],
                                legend: {
                                    data: ['统计图'],
                                    icon : 'roundRect',//icon为圆角矩形
                                    textStyle:{//图例文字的样式
                                        color:'#fff',
                                        fontSize:16
                                    }
                                },   
                                grid: {
                                    left: '2%',
                                    right: '2%',
                                    bottom: '3%',
                                    containLabel: true
                                },                                            
                                xAxis: {
                                    type: 'category',
                                    boundaryGap:false,
                                    // data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
                                    data:column,
                                    axisLine: {
                                        lineStyle: {
                                            color: "#fff"
                                        }
                                    }
                                },
                                yAxis: {
                                    type: 'value',
                                    splitLine: {
                                        show: false
                                    },
                                    axisLine: {
                                        lineStyle: {
                                            color: "#fff"
                                        }
                                    }
                                },
                                series: [{
                                    name:'预约数量',
                                    // data: [820, 1330, 901, 934, 1290, 500, 1320],
                                    data:paydata,
                                    type: 'line',
                                    smooth: true,
                                    areaStyle: {
                                        opacity: 0.4
                                    }

                                }]
                            };

                            // 使用刚指定的配置项和数据显示图表。
                            barChart.setOption(option); 
                        }//end if
                    }
                });
            });
            // 使用刚指定的配置项和数据显示图表。
            barChart.setOption(option);  
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});